
import edu.faytechcc.csc251.mvc.concrete.ColorController;
import edu.faytechcc.csc251.gui.ColorDisplayPanel;
import edu.faytechcc.csc251.mvc.concrete.ColorModel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JPanel;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author bryanc7064
 */
public class Application {

    static final ColorController controler = new ColorController();
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        ColorModel model = new ColorModel();
        //final ColorController controler = new ColorController();
        ColorDisplayPanel cdp = new ColorDisplayPanel();

        controler.addModel(model);
        controler.addView(cdp);

        model.initColorModel(Color.yellow);

        JFrame colorFrame = new JFrame();
        cdp.setPreferredSize(new Dimension(300, 300));
        colorFrame.getContentPane().add(cdp);
        colorFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        colorFrame.pack();
        colorFrame.setVisible(true);

        JFrame colorChooserFrame = new JFrame();
        JPanel panel = new JPanel();
        JButton button = new JButton("Change Color");
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                Color c = JColorChooser.showDialog(null, "Choose a Color", Color.yellow);
                if(c != null) {
                    controler.changeColor(c);
                }
            }
        });
        panel.add(button);
        colorChooserFrame.getContentPane().add(panel);
        colorChooserFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        colorChooserFrame.pack();
        colorChooserFrame.setVisible(true);
    }

}
